home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
asmutil
/
80x0393.zip
/
MODEX.ASM
< prev
next >
Wrap
Assembly Source File
|
1993-03-30
|
57KB
|
1,686 lines
;
; MODEX.ASM - A Complete Mode X Library
;
; By Matt Pritchard
; With considerable input from Michael Abrash
;
; The following information is donated to the public domain in
; the hopes that save other programmers much frustration.
;
; If you do use this code in a product, it would be nice if
; you include a line like 'Mode X routine by Matt Pritchard'
; in the credits. '
;
.MODEL Medium, Basic
.286
PAGE 255, 132
; ==== MACROS ====
OUT_16 MACRO Register, Value
MOV DX, Register ; Select Register
MOV AX, Value ; Get Out Value
OUT DX, AX ; Set Register(s)
ENDM
OUT_8 MACRO Register, Value
MOV DX, Register ; Select Register
MOV AL, Value ; Get Out Value
OUT DX, AL ; Set Register
ENDM
; ==== General Constants ====
False EQU 0
True EQU -1
b EQU BYTE PTR
w EQU WORD PTR
d EQU DWORD PTR
; ==== VGA Register Values ====
VGA_Segment EQU 0A000H ; Vga Memory Segment
ATTRIB_Ctrl EQU 03C0H ; VGA Attribute Controller
GC_Index EQU 03CEH ; VGA Graphics Controller
SC_Index EQU 03C4H ; VGA Sequencer Controller
SC_Data EQU 03C5H ; VGA Sequencer Data Port
CRTC_Index EQU 03D4H ; VGA CRT Controller
CRTC_Data EQU 03D5H ; VGA CRT Controller Data
MISC_OUTPUT EQU 03C2H ; VGA Misc Register
INPUT_1 EQU 03DAH ; Input Status #1 Register
DAC_WRITE_ADDR EQU 03C8H ; VGA DAC Write Addr Register
DAC_READ_ADDR EQU 03C7H ; VGA DAC Read Addr Register
PEL_DATA_REG EQU 03C9H ; VGA DAC/PEL data Register R/W
MAP_MASK EQU 02 ; Map Register #
READ_MAP EQU 04 ; Read Map Register #
MAP_MASK_PLANE1 EQU 0102h ; Map Register + Plane 1
START_DISP_HI EQU 0Ch ; CRTC Index: Display Start Addr Hi
START_DISP_LO EQU 0Dh ; CRTC Index: Display Start Addr Lo
PLANE_BITS EQU 03h ; Bits 0-1 of Xpos = Plane #
ALL_PLANES EQU 0Fh ; All Bit Planes Selected
ALL_PLANES_ON EQU 0F02h ; Map Register + All Bit Planes
CHAIN4_OFF EQU 0604h ; Chain 4 mode Off
ASYNC_RESET EQU 0100h ; (A)synchronous Reset
SEQU_RESTART EQU 0300h ; Sequencer Restart
; Constants Specific for these routines
NUM_MODES EQU 8 ; # of Mode X Variations
; Specific Mode Data Table format...
M_MiscR EQU 0 ; Value of MISC_OUTPUT register
M_Pages EQU 1 ; Maximum Possible # of pages
M_XSize EQU 2 ; X Size Displayed on screen
M_YSize EQU 4 ; Y Size Displayed on screen
M_XMax EQU 6 ; Maximum Possible X Size
M_YMax EQU 8 ; Maximum Possible Y Size
M_CRTC EQU 10 ; Table of CRTC register values
; ==== DGROUP STORAGE NEEDED (36 BYTES) =====
.DATA?
SCREEN_WIDTH DW 0 ; Width of a line in Bytes
SCREEN_WIDTHx4 DW 0 ; Width of a line in Pixels
SCREEN_HEIGHT DW 0 ; Veritcal Height in Pixels
LAST_PAGE DW 0 ; # of Display Pages
PAGE_ADDR DW 0, 0, 0, 0 ; Offsets to start of each page
PAGE_SIZE DW 0 ; Size of Page in Addr Bytes
DISPLAY_PAGE DW 0 ; Page # currently displayed
ACTIVE_PAGE DW 0 ; Page # currently active
CURRENT_PAGE DW 0 ; Offset of current Page
CURRENT_SEGMENT DW 0 ; Segment of VGA memory
CURRENT_XOFFSET DW 0 ; Current Display X Offset
CURRENT_YOFFSET DW 0 ; Current Display Y Offset
CURRENT_MOFFSET DW 0 ; Current Start Offset
MAX_XOFFSET DW 0 ; Current Display X Offset
MAX_YOFFSET DW 0 ; Current Display Y Offset
.CODE
; Data Tables, Put in Code Segement for Easy Access
; (Like when all the other Segment Registers are in
; use!!) and reduced DGROUP requirements...
LEFT_CLIP_MASK DB 0FH, 0EH, 0CH, 08H
RIGHT_CLIP_MASK DB 01H, 03H, 07H, 0FH
MODE_TABLE:
DW OFFSET MODE_320x200, OFFSET MODE_320x400
DW OFFSET MODE_360x200, OFFSET MODE_360x400
DW OFFSET MODE_320x240, OFFSET MODE_320x480
DW OFFSET MODE_360x240, OFFSET MODE_360x480
MODE_320x200: ; Data for 320 by 200 Pixels
DB 063h ; 400 scan Lines & 25 Mhz Clock
DB 4 ; Maximum of 4 Pages
DW 320, 200 ; Displayed Pixels (X,Y)
DW 1302, 816 ; Max Possible X and Y Sizes
;CRTC Setup Data....
DW 00014H ; Dword Mode off
DW 0E317H ; turn on Byte Mode
DW 00000h ; End of CRTC Data for 320x200
MODE_320x400: ; Data for 320 by 400 Pixels
DB 063h ; 400 scan Lines & 25 Mhz Clock
DB 2 ; Maximum of 2 Pages
DW 320, 400 ; Displayed Pixels X,Y
DW 648, 816 ; Max Possible X and Y Sizes
;CRTC Setup Data....
DW 04009H ; Cell Heigth (1 Scan Line)
DW 00014H ; Dword Mode off
DW 0E317H ; turn on Byte Mode
DW 00000h ; End of CRTC Data for 320x400
MODE_360x240: ; Data for 360 by 240 Pixels
DB 0E7h ; 480 scan Lines & 28 Mhz Clock
DB 3 ; Maximum of 3 Pages
DW 360, 240 ; Displayed Pixels X,Y
DW 1092, 728 ; Max Possible X and Y Sizes
;CRTC Setup Data....
DW 06B00H ; Horz total
DW 05901H ; Horz Displayed
DW 05A02H ; Start Horz Blanking
DW 08E03H ; End Horz Blanking
DW 05E04H ; Start H Sync
DW 08A05H ; End H Sync
DW 00D06H ; Vertical Total
DW 03E07H ; Overflow
DW 04109H ; Cell Heigth (2 Scan Lines)
DW 0EA10H ; V Sync Start
DW 0AC11H ; V Sync End/Prot Cr0 Cr7
DW 0DF12H ; Vertical Displayed
DW 00014H ; Dword Mode off
DW 0E715H ; V Blank Start
DW 00616H ; V Blank End
DW 0E317H ; turn on Byte Mode
DW 00000h ; End of CRTC Data for 360x240
MODE_360x480: ; Data for 360 by 480 Pixels
DB 0E7h ; 480 scan Lines & 28 Mhz Clock
DB 1 ; Only 1 Page Possible
DW 360, 480 ; Displayed Pixels X,Y
DW 544, 728 ; Max Possible X and Y Sizes
;CRTC Setup Data....
DW 06B00H ; Horz total
DW 05901H ; Horz Displayed
DW 05A02H ; Start Horz Blanking
DW 08E03H ; End Horz Blanking
DW 05E04H ; Start H Sync
DW 08A05H ; End H Sync
DW 00D06H ; Vertical Total
DW 03E07H ; Overflow
DW 04009H ; Cell Heigth (1 Scan Line)
DW 0EA10H ; V Sync Start
DW 0AC11H ; V Sync End/Prot Cr0 Cr7
DW 0DF12H ; Vertical Displayed
DW 00014H ; Dword Mode off
DW 0E715H ; V Blank Start
DW 00616H ; V Blank End
DW 0E317H ; turn on Byte Mode
DW 00000h ; End of CRTC Data for 360x480
MODE_320x240: ; Data for 320 by 240 Pixels
DB 0E3h ; 480 scan Lines & 25 Mhz Clock
DB 3 ; Maximum of 3 Pages
DW 320, 240 ; Displayed Pixels X,Y
DW 1088, 818 ; Max Possible X and Y Sizes
DW 00D06H ; Vertical Total
DW 03E07H ; Overflow
DW 04109H ; Cell Heigth (2 Scan Lines)
DW 0EA10H ; V Sync Start
DW 0AC11H ; V Sync End/Prot Cr0 Cr7
DW 0DF12H ; Vertical Displayed
DW 00014H ; Dword Mode off
DW 0E715H ; V Blank Start
DW 00616H ; V Blank End
D